﻿using System;
using HiTeachers.Data.Manager;
using HiTeachers.Entities;
using HiTeachers.Interfaces;
using NHibernate;

namespace HiTeachers.Data
{
    public class SiteConfigDao : AbstractNHibernateDao<SiteConfig, int>, ISiteConfigDao
    {
        public SiteConfig GetByTextKey(string textKey)
        {
            try
            {
                const string hsql = "from SiteConfig scfg where scfg.TextKey = :textKey";

                IQuery query = NHibernateSession.CreateQuery(hsql);
                query.SetString("textKey", textKey);

                return query.UniqueResult<SiteConfig>();
            }
            catch (Exception)
            {
                return null;
            }
        }
    }
}
